package xinyu.customer.news.data;

import com.logos.common.source.network.entity.BaseNetEntity;

import java.util.List;

import xinyu.customer.bean.NewsMainNetTopBean;
import xinyu.customer.bean.NewsNoteBean;

public class NewsTabNotePresenter implements NewsTabNoteContract.Presenter {

    private NewsTabNoteContract.View mView;
    private NewsTabNoteDataSource mDataSource;

    public NewsTabNotePresenter(NewsTabNoteContract.View view, NewsTabNoteDataSource dataSource) {

        if (view == null || dataSource == null) {
            throw new IllegalArgumentException("view and dataSource must not be empty");
        }

        mView = view;
        mDataSource = dataSource;
        view.setPresenter(this);
    }


    @Override
    public void create() {

    }

    @Override
    public void destroy() {

    }

    @Override
    public void getNoteList(int pageNum,String custId) {
        mView.showLoading();
        mDataSource.getNewsTabNoteListData(pageNum, custId, new NewsTabNoteDataSource.NewsTabNoteCallback() {
            @Override
            public void onNewsTabNoteListComplete(BaseNetEntity<List<NewsNoteBean>> listBaseNetEntity) {
                mView.hideLoading();
                mView.onNoteListSuccess(listBaseNetEntity);
            }

            @Override
            public void onFailed(int errorId, String errorMessage) {
                mView.hideLoading();
                mView.showMessage(errorMessage);
            }
        });
    }
}
